//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.tuiofx.internal.gesture;

import TUIO.TuioCursor;
import javafx.event.EventTarget;
import org.tuiofx.internal.base.FXCoordinates;
import org.tuiofx.internal.util.LogUtils;

public class TuioTouchPoint {
    private final int id;
    private float cursorX;
    private float cursorY;
    private double sceneX;
    private double sceneY;
    private double screenX;
    private double screenY;
    private double lastSceneX = 0.0;
    private double lastSceneY = 0.0;
    private final Integer sessionID;
    private TuioCursor cursor;
    private State state;
    private EventTarget targetNode;
    private EventTarget currentTargetNode;

    public TuioTouchPoint copyFor(EventTarget newTarget) {
        TuioTouchPoint newTouchPoint = new TuioTouchPoint(this.cursor, this.screenX, this.screenY, this.sceneX, this.sceneY, this.state);
        newTouchPoint.setTargetNode(newTarget);
        newTouchPoint.setCurrentTargetNode(newTarget);
        return newTouchPoint;
    }

    public TuioTouchPoint(TuioCursor cursor, double screenX, double screenY, double sceneX, double sceneY, State state) {
        this.cursor = cursor;
        this.cursorX = cursor.getX();
        this.cursorY = cursor.getY();
        this.sessionID = (int) cursor.getSessionID();
        this.id = cursor.getCursorID();
        this.setScreenX(screenX);
        this.setScreenY(screenY);
        this.setSceneX(sceneX);
        this.setSceneY(sceneY);
        this.lastSceneX = sceneX;
        this.lastSceneY = sceneY;
        this.state = state;
    }

    public double getScreenX() {
        return this.screenX;
    }

    public void setScreenX(double position) {
        this.screenX = position;
    }

    public double getScreenY() {
        return this.screenY;
    }

    public void setScreenY(double position) {
        this.screenY = position;
    }

    public double getLastSceneX() {
        return this.lastSceneX;
    }

    public double getLastSceneY() {
        return this.lastSceneY;
    }

    public State getState() {
        return this.state;
    }

    public Integer getSessionID() {
        return this.sessionID;
    }

    public EventTarget getTargetNode() {
        return this.targetNode;
    }

    public void setTargetNode(EventTarget targetNode) {
        this.targetNode = targetNode;
    }

    public void update(EventTarget targetNode, double lastSceneX, double lastSceneY) {
        this.targetNode = targetNode;
        this.lastSceneX = lastSceneX;
        this.lastSceneY = lastSceneY;
    }

    public float getCursorX() {
        return this.cursorX;
    }

    public float getCursorY() {
        return this.cursorY;
    }

    public double getSceneX() {
        return this.sceneX;
    }

    public double getSceneY() {
        return this.sceneY;
    }

    public void setSceneX(double sceneX) {
        this.sceneX = sceneX;
    }

    public void setSceneY(double sceneY) {
        this.sceneY = sceneY;
    }

    public void setCurrentTargetNode(EventTarget currentTargetNode) {
        this.currentTargetNode = currentTargetNode;
    }

    public EventTarget getCurrentTargetNode() {
        return this.currentTargetNode;
    }

    public void setFXCoordinates(FXCoordinates fXCoords) {
        this.sceneX = fXCoords.getSceneXY().getX();
        this.sceneY = fXCoords.getSceneXY().getY();
        this.screenX = fXCoords.getScreenXY().getX();
        this.screenY = fXCoords.getScreenXY().getY();
    }

    public int getId() {
        return this.id;
    }

    public TuioCursor getCursor() {
        return this.cursor;
    }

    public boolean equals(Object obj) {
        if (obj instanceof TuioTouchPoint) {
            TuioTouchPoint touchP = (TuioTouchPoint) obj;
            if (touchP.getSessionID() < 0) {
                LogUtils.error("touch sessionID sould not be null.");
            }
            return touchP.getSessionID().equals(this.getSessionID());
        } else {
            return false;
        }
    }

    public String toString() {
        StringBuilder result = new StringBuilder();
        result.append("TouchPoint ->  sessionID=" + this.sessionID);
        result.append(" state=" + this.state);
        result.append(" targetNode=" + this.targetNode.toString());
        result.append(" screenX=" + this.screenX + " screenY=" + this.screenY);
        result.append(" sceneX=" + this.sceneX + " sceneY=" + this.sceneY);
        return result.toString();
    }

    public static enum State {
        STARTED,
        MOVED,
        ENDED;

        private State() {
        }
    }
}
